import xlrd

class readData:
    def read_data(self,i,n):
        wb = xlrd.open_workbook(r'D:\pythonproject\自动化_1封装\data\测试数据.xls')
        sheet = wb.sheet_by_index(i)
        data = []


        for row in range(1, sheet.nrows):
            row_values = []
            for col in range(n):  # 遍历前n列
                cell_value = sheet.cell_value(row, col)
                cell_type = sheet.cell_type(row, col)

                # 如果是数字类型，转为整数（直接截断）
                if cell_type == xlrd.XL_CELL_NUMBER:
                    row_values.append(int(cell_value))
                else:
                    row_values.append(cell_value)

            data.append(tuple(row_values))
        return data
